package controllers

import (
	"dataService/models"
	"fmt"
	"github.com/astaxie/beego"
)

type ResponseInfo struct {
}

type AircraftController struct {
	beego.Controller
}

func (this *AircraftController) Post() {
	//var ob models.Object
	//json.Unmarshal(this.Ctx.RequestBody, &ob)
	//objectid := models.AddOne(ob)
	//this.Data["json"] = "{\"ObjectId\":\"" + objectid + "\"}"
	//this.ServeJson()
}

func (this *AircraftController) Get() {
	aircraftId := this.Ctx.Params[":objectId"]
	if aircraftId != "" {
		ob, err := models.GetOne(aircraftId)
		if err != nil {
			this.Data["json"] = err
		} else {
			this.Data["json"] = ob
		}
	} else {

		obs := models.GetAll()
		this.Data["json"] = obs

	}
	this.ServeJson()
}

func (this *AircraftController) Put() {
	//objectId := this.Ctx.Params[":objectId"]
	//var ob models.Object
	//json.Unmarshal(this.Ctx.RequestBody, &ob)

	//err := models.Update(objectId, ob.Score)
	//if err != nil {
	//	this.Data["json"] = err
	//} else {
	//	this.Data["json"] = "update success!"
	//}
	//this.ServeJson()
}

func (this *AircraftController) Delete() {
	//objectId := this.Ctx.Params[":objectId"]
	//models.Delete(objectId)
	//this.Data["json"] = "delete success!"
	//this.ServeJson()
}
